﻿using System;
using System.Windows.Forms;

namespace SVM_Sharp
{
    public partial class FormEditParameters : Form
    {
        public FormEditParameters()
        {
            InitializeComponent();
        }

        public bool IsScaleCheckd()
        {
            return ckb_scale.Checked;
        }

        public void Carrega_resultados(System.Data.DataRow _tmprow)
        {
            txt_c.Text = System.Convert.ToString(_tmprow[SVM_SharpCtrl.ID_C]);
            txt_weightP.Text = System.Convert.ToString(_tmprow[SVM_SharpCtrl.ID_WEIGHTPOS]);
            txt_weightN.Text = System.Convert.ToString(_tmprow[SVM_SharpCtrl.ID_WEIGHTNEG]);
            ckb_scale.Checked = System.Convert.ToBoolean(_tmprow[SVM_SharpCtrl.ID_SCALED]);
            chkMultiThread.Checked = System.Convert.ToBoolean(_tmprow[SVM_SharpCtrl.ID_MULTITHREAD]);
            string kernel_type = System.Convert.ToString(_tmprow[SVM_SharpCtrl.ID_KERNEL]);
            switch (kernel_type)
            {
                case "0":
                    {
                        rbx_lin.Checked = true;
                        break;
                    }

                case "1":
                    {
                        rbx_pol.Checked = true;
                        txt_degree.Text = System.Convert.ToString(_tmprow[SVM_SharpCtrl.ID_DEGREE]);
                        txt_gamma.Text = System.Convert.ToString(_tmprow[SVM_SharpCtrl.ID_GAMMA]);
                        txt_coef.Text = System.Convert.ToString(_tmprow[SVM_SharpCtrl.ID_COEFFICIENT0]);
                        break;
                    }

                case "2":
                    {
                        rbx_RBF.Checked = true;
                        txt_gamma.Text = System.Convert.ToString(_tmprow[SVM_SharpCtrl.ID_GAMMA]);
                        txt_coef.Text = System.Convert.ToString(_tmprow[SVM_SharpCtrl.ID_COEFFICIENT0]);
                        break;
                    }

                case "3":
                    {
                        rbx_sig.Checked = true;
                        txt_coef.Text = System.Convert.ToString(_tmprow[SVM_SharpCtrl.ID_COEFFICIENT0]);
                        break;
                    }
            }
        }

        private void rbx_RBF_CheckedChanged(object sender, System.EventArgs e)
        {
            txt_degree.Enabled = false;
            txt_coef.Enabled = false;
            txt_gamma.Enabled = true;
            lbl_coef0_sig.Enabled = false;
            lbl_degree.Enabled = false;
            lbl_gamma_rbf.Enabled = true;
        }

        private void rbx_lin_CheckedChanged(object sender, System.EventArgs e)
        {
            txt_degree.Enabled = false;
            txt_coef.Enabled = false;
            txt_gamma.Enabled = false;
            lbl_coef0_sig.Enabled = false;
            lbl_degree.Enabled = false;
            lbl_gamma_rbf.Enabled = false;
        }

        private void rbx_pol_CheckedChanged(object sender, System.EventArgs e)
        {
            txt_degree.Enabled = true;
            txt_coef.Enabled = true;
            txt_gamma.Enabled = true;
            lbl_coef0_sig.Enabled = true;
            lbl_degree.Enabled = true;
            lbl_gamma_rbf.Enabled = true;
        }

        private void rbx_sig_CheckedChanged(object sender, System.EventArgs e)
        {
            txt_degree.Enabled = false;
            txt_coef.Enabled = true;
            txt_gamma.Enabled = true;
            lbl_coef0_sig.Enabled = true;
            lbl_degree.Enabled = false;
            lbl_gamma_rbf.Enabled = true;
        }

        private void ChkMultiThreadCheckedChanged(object sender, EventArgs e)
        {
            SVM.PARALLEL_MODE.ENABLE_MULTI_THREAD = chkMultiThread.Checked;
        }
    }
}